package com.apps.helper;




//import com.apps.base.Admin.model.po.Admin;
//import com.apps.base.Member.model.po.Member;

import javax.servlet.http.HttpSession;

/**
 * 用户上下文
 * @author kingapex
 *
 */
public abstract class MemberConextHelper {

	/**
	 * 用户端用
	 */
	public static final String CURRENT_MEMBER_KEY="curr_member";
	/**
	 * 管理后台用
	 */
	public static final String CURRENT_ADMIN_KEY="curr_admin";

	/**
	 * 获取当前登录的会员
	 * @return 如果没有登录返回null
	 */
//	public static Member getCurrentMember()
//    {
//
//		HttpSession sessonContext = ThreadContextHelper.getSession();
//		if (sessonContext != null) {
//			try {
//				Member member = (Member) sessonContext.getAttribute(MemberConextHelper.CURRENT_MEMBER_KEY);
//				return member;
//			} catch (IllegalStateException e) {
//				return null;
//			}
//		}
//		return null;
//	}

//	public static Admin getCurrentAdmin()
//	{
//
//		HttpSession sessonContext = ThreadContextHelper.getSession();
//		if (sessonContext != null) {
//			try {
//				Admin admin = (Admin) sessonContext.getAttribute(MemberConextHelper.CURRENT_ADMIN_KEY);
//				return admin;
//			} catch (IllegalStateException e) {
//				return null;
//			}
//		}
//		return null;
//	}
	/**
	 * 从session中清除当前用户的登录信息
	 */
	public static void cleanCurrentMember()
	{
		ThreadContextHelper.getSession().removeAttribute(MemberConextHelper.CURRENT_MEMBER_KEY);
	}


}
